﻿using System;

namespace Fly.Common.Extensions
{
    /// <summary>
    /// Guid 扩展类
    /// </summary>
    public static class GuidExtensions
    {
        #region 根据GUID获取19位的唯一数字序列
        /// <summary>
        /// 根据GUID获取19位的唯一数字序列
        /// </summary>
        public static long GuidToLongId()
        {
            byte[] buffer = Guid.NewGuid().ToByteArray();
            return BitConverter.ToInt64(buffer, 0);
        }
        /// <summary>
        /// 将指定的GUID转换为19位的唯一数字序列
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static long ToInt64(this Guid value)
        {
            return BitConverter.ToInt64(value.ToByteArray(),0);
        }
        #endregion
    }
}
